package com.swust.member.controller;

import com.swust.common.resp.CommonResp;
import com.swust.member.req.PassengerQueryReq;
import com.swust.member.req.PassengerSaveReq;
import com.swust.member.resp.PageResp;
import com.swust.member.resp.PassengerQueryResp;
import com.swust.member.service.PassengerService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * @author Const
 */
@RestController
@RequestMapping("/passenger")
public class PassengerController {

    @Resource
    private PassengerService passengerService;


    @PostMapping("/save")
    public CommonResp<Long> register(@Valid @RequestBody PassengerSaveReq req) {
        passengerService.save(req);
        return new CommonResp<>();
    }

    @GetMapping("/query-list")
    public CommonResp<PageResp<PassengerQueryResp>> queryList(PassengerQueryReq req) {
        PageResp<PassengerQueryResp> queryList = passengerService.queryList(req);
        return new CommonResp<>(queryList);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        passengerService.delete(id);
        return new CommonResp<>();
    }

}
